session 相关问题

会话是指单个客户端与服务器之间的通信。会话特定于用户,并且对于每个用户,创建新会话以跟踪来自该用户的所有请求。

如何禁用 PHP 会话 cookie?

我正在编写 PHP 代码,我想使用 POST 自己传递会话 id。我不想要 cookie 来存储会话,因为当用户退出 POST 周期时它应该会丢失。 PHP自动化...

回答 7 投票 0

重新混合会话在页面刷新时未持续

我遇到一个问题,当刷新页面或用户导航到新的子路由时,Remix 不会保留会话。我查看了其他问题,不幸的是,以下......

回答 1 投票 0

在 Chrome 上随机 php 会话丢失,但在 Firefox 上则不然

我的服务器上有第一个文件 file1.php,它创建一个会话变量并显示它(我将此文件保持打开状态)。 http://localhost/file1.php : 会话开始(); $_SESSION['测试'] = "...

回答 1 投票 0

我如何从客户端更改asp网站中的会话ID

如果可以的话我该怎么办 我尝试过但不起作用 需要测试它是如何工作的如果某些东西有效用户可以在更改我们使用的会话 ID 后登录 c# 页面,所以如果它是可变的,如何...

回答 1 投票 0

基于会话的 ASP.NET Core 6 Web API 登录在 [Authorize] 端点上给出 404 错误,可能是什么问题?

我正在向 ASP.NET Core 6 (Web API) 项目的后端添加基于会话的用户登录系统。我设置好了,当使用邮递员进行测试时,我的登录端点返回一个会话 cookie 并且......

回答 2 投票 0

计算 SpringEL 表达式时出现异常:“#session.removeAttribute('message') in thymeleaf”

我正在尝试从我的 html 文件中删除这样的视图: 我正在尝试从我的 html 文件中删除这样的视图: <div th:if="${session.message}" th:classappend="${session.message.type}" class="alert" role="alert"> <p class = "text-center " th:text="${session.message.content}"></p> <th:block th:text="${#session.removeAttribute('message')}"></th:block> </div> 但是它抛出错误 Caused by: org.attoparser.ParseException: Exception evaluating SpringEL expression: "#session.removeAttribute('message')" (template: "signup" - line 19, col 43) at org.attoparser.MarkupParser.parseDocument(MarkupParser.java:393) at org.attoparser.MarkupParser.parse(MarkupParser.java:257) at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:230) ... 48 more 这是我的控制器代码... User addedUser = this.userRepository.save(user); model.addAttribute("user", new User()); session.setAttribute("message", new Message("Successfully Register", "alert-success")); return "signup"; } catch (Exception e) { e.printStackTrace(); model.addAttribute("user", user); session.setAttribute("message", new Message("Server Error !!" + e.getMessage(), "alert-danger")); return "signup"; } 任何人都可以帮我解决这个问题吗...? 尝试从会话中删除属性但无法执行此操作... 此方法已不再使用 您必须创建一个实用程序 bean 并创建一个会话删除方法,然后在 thymeleaf 中使用该方法来删除属性 班级: package com.Contact.config; import org.springframework.context.annotation.Bean; import org.springframework.stereotype.Component; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; import jakarta.servlet.http.HttpSession; @Component public class sessionUtilityBean { @Bean public void removeMessageFromSession() { try { System.out.println("removing message form session "); HttpSession session = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest().getSession(); session.removeAttribute("message"); } catch (Exception e) { e.printStackTrace(); } } } 然后使用thymeleaf中的方法: <div th:if="${session.message}" th:classappend="${session.message.type}" class="alert " role="alert"> <p th:text="${session.message.content}"></p> <th:block th:text="${@sessionUtilityBean.removeMessageFromSession()}"></th:block> </div>

回答 1 投票 0

rails 如何知道 cookie 何时过期

我使用 cookie_store 来存储我的用户会话: Rails.application.config.session_store :cookie_store, key: '_session', expire_after: 1.month 我相信这会按照图书馆的说法执行...但是...

回答 1 投票 0

AzureServiceBus:处理同一会话的所有消息,如果失败则回滚

我有以下流程,我认为使用 AzureServiceBus 和会话很容易实现: 我有一个订阅,可以从一条消息中创建 +5 条消息并发送所有这些混乱......

回答 1 投票 0

Codeigniter 无法加载库

最初,我以为由于在 Codeigniter 中使用模块化扩展而导致加载库时出现问题。 然而我发现即使全新安装了 codeigniter 我也无法加载

回答 6 投票 0

Codeigniter 会话无法在实时服务器上运行

当打开 codeigniter 项目 localhost 时,它们正常工作并在服务器中打开,然后出现无效路径错误 遇到 PHP 错误 严重性:警告 消息:mkdir():无效路径

回答 8 投票 0

Laravel 5.3,当验证失败时会话不闪烁任何内容

您好,我有以下表格: {{ csrf_field() }} 嗨,我有以下表格: <form action="{{ route('postCustomerInfo') }}" method="post" class="shipping-form"> {{ csrf_field() }} <input type="hidden" name="note" value="hidden_note_field"> <input type="hidden" name="country_id" value="1"> <div class="form-checkout"> <div class="form-fields"> @if($errors->has('name'))<div class="input-box error" data-error="{{ $errors->first('name') }}"> @else<div class="input-box"> @endif <input type="text" name="name" value={{ old('name') }}> <label for="">name</label> </div> @if($errors->has('phone'))<div class="input-box error" data-error="{{ $errors->first('phone') }}"> @else <div class="input-box"> @endif <input type="text" name="phone" value={{ old('phone') }} onkeypress='return event.charCode >= 48 && event.charCode <= 57'> <label for="">phone</label> </div> @if($errors->has('email'))<div class="input-box error" data-error="{{ $errors->first('email') }}"> @else <div class="input-box"> @endif <input type="text" name="email" value="{{ old('email') }}"> <label for="">email</label> </div> <div class="row"> <div class="col-xs-5 col-sm-5 col-md-6"> @if($errors->has('city'))<div class="input-box error" data-error="{{ $errors->first('city') }}"> @else<div class="input-box"> @endif <input type="text" name="city" value="{{ old('city') }}"> <label for="">city</label> </div> </div> <div class="col-xs-7 col-sm-7 col-md-6"> @if($errors->has('postal_code'))<div class="input-box error" data-error="{{ $errors->first('postal_code') }}"> @else<div class="input-box error" data-error="{{ $errors->first('postal_code') }}"> @endif <input type="text" name="postal_code" value="{{ old('postal_code') }}"> <label for="">postal code</label> </div> </div> </div> @if($errors->has('address_line'))<div class="input-box error" data-error="{{ $errors->first('address_line') }}"> @else<div class="input-box error" data-error="{{ $errors->first('address_line') }}"> @endif <input type="text" name="address_line" value={{ old('address_line') }}> <label for="">address</label> </div> </div> </div> </form> <a href="" class="btn action">Go to <span>shipping</span></a> 我通过jquery提交表单 $(document).ready(function () { $('.btn.action').on('click','',function (e) { e.preventDefault(); var $form = $('form.shipping-form'); $form.submit(); }); }); 我的 FormRequest 类是: class CustomerInformationRequest extends FormRequest { /** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { return true; } /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { return [ 'name' => 'required|min:5|max:50', 'email' => 'required|email|min:5|max:50', 'phone' => 'required|min:3|max:20', 'country_id' => 'required', 'city' => 'required|min:3', 'postal_code' => 'required|digits:4', 'address_line' => 'required|min:5|max:50', 'note' => '' ]; } } 我在 StackOverflow 中读到了这个帖子:Laravel 5 输入旧为空但我不认为这实际上是我的问题。而且我的 {{ old('values') }} 仍然是空的,我不知道为什么?有什么想法吗? /** * The application's global HTTP middleware stack. * * These middleware are run during every request to your application. * * @var array */ protected $middleware = [ \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class, ]; /** * The application's route middleware groups. * * @var array */ protected $middlewareGroups = [ 'web' => [ \App\Http\Middleware\EncryptCookies::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, \App\Http\Middleware\BeforeAutoTrimmer::class ], 'api' => [ 'throttle:60,1', 'bindings', ], ]; /** * The application's route middleware. * * These middleware may be assigned to groups or used individually. * * @var array */ protected $routeMiddleware = [ 'auth' => \Illuminate\Auth\Middleware\Authenticate::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, 'can' => \Illuminate\Auth\Middleware\Authorize::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'setCurrency'=>\App\Http\Middleware\SetCurrency::class, 'checkout'=>\App\Http\Middleware\Checkout::class, ];}`. 我补充了 \App\Http\Middleware\BeforeAutoTrimmer::class 谁关心修剪我所有的表格: public function handle($request, Closure $next) { $request->merge(array_map('trim', $request->all())); return $next($request); } , 这 'setCurrency'=>\App\Http\Middleware\SetCurrency::class 谁关心从数据库到会话设置货币: `公共函数句柄($request, 闭包$next) { if(!Session::has('货币')) { $currency = 设置::where('setting_name', 'currency')->select('setting_value as code')->first(); $currencyData = 货币::where('code', $currency->code)->select('symbol_position', 'symbol', 'code')->first(); Session::put('currency', $currencyData); Session::save(); return $next($request); } return $next($request);}` 和'checkout'=>\App\Http\Middleware\Checkout::class,如果会话中的购物车是空的,谁愿意重定向我: `公共函数句柄($request, Closure $next) { if(!Session::has('cart')){ return redirect()->route('home'); } return $next($request); }` 但其余的我认为它们是 laravel 的默认设置,我没有碰它们

回答 1 投票 0

如何向会话表添加自定义字段

我目前使用的是 Symfony 2.1.8 和内置的 PdoSessionHandler。 我想在会话表中添加一个 user_id 字段来标识会话属于哪个(登录)用户。这个想法是......

回答 2 投票 0

未设置 Express 会话 cookie。后端部署在 Render 上,前端使用 Vercel 部署。但可以在本地主机上运行

我这两天一直在尝试解决这个问题,但还没有找到解决方案。 我的应用程序分为客户端和服务器。客户端托管在 vercel 上,服务器托管在 Re...

回答 1 投票 0

在 Docker php-apache 中更改 session.gc_maxlifetime 和 session.cookie_lifetime

我想增加 php.ini 中的会话生命周期。 不幸的是,由于其他情况(例如使用一些 compozer 的东西),我无法在 php 脚本本身中使用 ini_set 。 不管怎样,通常是在 root 上...

回答 1 投票 0

使用python请求从shopee抓取产品返回90309999

自 2022 年以来,我能够使用带有 User-Agent 和 From 标头的 python 请求来废弃 Shopee 列表。然而,自上周以来,我一直收到来自 {"

回答 1 投票 0

即使我登录了 Facebook,Facebook 会话也已过期

我正在使用带有rails的facebooker,当我通过facebook connect登录时,对于新用户注册,当我检索名字等详细信息时,我得到一个会话过期。 请注意,当我浏览到

回答 1 投票 0

Moodle 抛出 Cannot find session record 错误

用户时不时地注销,我在错误日志中不断收到以下错误 默认异常处理程序:密钥不正确调试: 错误代码: 无效的密钥 *第117行 /auth/用户密钥/

回答 0 投票 0

如何在会话中存储用户数据?

我想用刚刚登录的相关用户的所有数据库数据填充我的 $_SESSION 数组。 就像数据库中的“FIRST_NAME”将是 $_SESSION["FIRST_NAME"]; 什么是...

回答 2 投票 0

在会话中存储用户 ID 安全吗?

我已经创建了登录页面和注册页面,现在我想使用它来密码保护页面并拥有显示特定于该用户的信息的页面。 会存储您的用户 ID...

回答 2 投票 0

wicket/Jetty:避免为活动请求创建新的 Http 会话

我正在开发一个 Wicket 应用程序 (wicket 8),为了将其容器化,我添加了一个活性端点,例如 GET /probe/,我在虚拟 ProbeApplication(非身份验证应用程序)中处理该端点

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.